import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;

public class Main {





    //最长回文子序列
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        char[] s = in.next().toCharArray();
        int n= s.length;
        int[][] dp = new int[n][n];
        for(int i = n-1;i>=0;i--){
            dp[i][i] = 1;
            for(int j = i+1;j<n;j++){
                if(s[i] == s[j]) dp[i][j] = dp[i+1][j-1]+2;
                else dp[i][j] = Math.max(dp[i+1][j],dp[i][j-1]);
            }
        }
        System.out.println(dp[0][n-1]);
    }










    //集合
    public static void main2(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int m = in.nextInt();
        TreeSet<Integer> set = new TreeSet<>();
        for(int i = 0;i<n;i++){
            int x = in.nextInt();
            set.add(x);
        }
        for (int i = 0; i < m; i++) {
            int x = in.nextInt();
            set.add(x);
        }
        int h = 0;
        for (int x:set) {
            System.out.print(x);
            h++;
            if(h != set.size()-1){
                System.out.print(" ");
            }
        }
    }













    //爱丽丝的人偶
    public static void main1(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int left = 1;
        int right = n;
        while(left<=right){
            System.out.print(left+" ");
            left++;
            if(left<=right){
                System.out.println(right + " ");
                right--;
            }
        }
    }
}
